package com.fowo.api.service.handleWork;

import cn.hutool.core.lang.Assert;
import com.fowo.api.model.ship.plans.ShipPlansMarkExpediteAction;
import com.fowo.api.model.ship.plans.ShipPlansVo;
import com.fowo.api.model.ship.plans.sub.ShipPlansSubItemVo;
import com.fowo.api.service.ShipPlansService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ShipPlansMarkExpedite implements ShipPlansMarkExpediteAction {

    @Resource
    private ShipPlansService shipPlansService;

    @Override
    public void run(Long id) throws Exception {
        ShipPlansVo shipPlansVo = shipPlansService.getVoById(id);
        Assert.notNull(shipPlansVo,"单据不存在");

        for(ShipPlansSubItemVo subItemVo : shipPlansVo.getProductList()){
            subItemVo.setIsUrgent(true);
        }
        shipPlansService.update(shipPlansVo);
    }
}
